package com.ty.utils.ip;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * 封装ip相关信息：<br/>
 * 目前一条<b>IP记录</b>只有两个字段，ip所在的国家和地区；<br/>
 * 一条<b>IP范围记录</b>，不仅包括国家和区域，也包括起始IP和结束IP
 * 
 * @author Tommy
 * 
 *         2013-2-27
 */
@Data
@AllArgsConstructor
public class IPLocation {

	private String country;
	private String area;
	private String ip;
	private String beginIp;
	private String endIp;

	private String os;

	public IPLocation() {
	}

	public IPLocation(String country, String area) {
		this.country = country;
		this.area = area;
	}

	public IPLocation(String country, String area, String ip) {
		this.country = country;
		this.area = area;
		this.ip = ip;
	}

	public void setArea(String area) {
		// 如果为局域网，纯真IP地址库的地区会显示CZ88.NET,这里把它去掉
		if ("CZ88.NET".equals(area.trim()) || "保留地址".equals(area.trim())) {
			this.area = "局域网";
			return;
		}
		this.area = area;
	}
}
